//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Mon Sep 16 17:43:17 2013 by ROOT version 5.32/01
// from TTree ampt/parton level from AMPT
// found on file: ampt_output.root
//////////////////////////////////////////////////////////

#ifndef CBNTanalyser_h
#define CBNTanalyser_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TSelector.h>

// Header file for the classes stored in the TTree if any.
#include <vector>
#include "Rtypes.h"
#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include "TFile.h"
#include "TChain.h"
#include "TTree.h"
#include "TBranch.h"
#include "TLeaf.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TMath.h"
#include "TComplex.h"
//#include "TLorentzVector.h"
#include "TLegendEntry.h"
#include "TProfile.h"
using namespace std;

// Fixed size dimensions of array or collections stored in the TTree if any.

class CBNTanalyser : public TSelector {
public :
   TTree          *fChain;   //!pointer to the analyzed TTree or TChain
   TFile *temproot;
   // Added by Leon//////////////////
   double pt_tot;
   double n_tot;
   ofstream look; 
   TH1F *ptptpt;
   TH1F *Ncol_init_low;
   TH1F *Ncol_init_high;
   TH1F *Ncol_final_low;
   TH1F *Ncol_final_high;
   TH1F *initial_phi_0;
   TH1F *initial_phi_1;
   TH1F *initial_phi_2;
   TH1F *initial_phi_3;
   TH1F *dpt_gain;
   TH1F *f_initial_phi_0;
   TH1F *f_initial_phi_1;
   TH1F *f_initial_phi_2;
   TH1F *f_initial_phi_3;
   TH2F *Final_init_pt;
   TH2F *Final_init_phi;
   TH2F *Final_init_phi_1;
   TH2F *Final_init_phi_3;
   TH2F *initial_pt_t;
   TProfile *dptvsN_1;
   TProfile *dptvsN_2;
   TProfile *dptvsN_3;
   TProfile *dptvsN_4;
   TProfile *rptvsN_1;
   TProfile *rptvsN_2;
   TProfile *rptvsN_3;
   TProfile *rptvsN_4;
   TProfile *iptvsN_1;
   TProfile *iptvsN_2;
   TProfile *iptvsN_3;
   TProfile *iptvsN_4;
   TProfile *nVsDpt_1;
   TProfile *nVsDpt_2;
   TProfile *nVsDpt_3;
   TProfile *nVsDpt_4;
   TH2F *fptvsN_1;
   TH2F *fptvsN_2;
   TH2F *fptvsN_3;
   TH2F *fptvsN_4;
   TH2F *final_phi_ipt[11];
   TH2F *init_phi_ipt[11];
   TH2F *final_phi_fpt[11];
   TH2F *init_phi_fpt[11];
   TH2F *step_phi_pt[11];
   TH2F *pt_ncoll;
   TH3F *init_cos_init_pt_n;
   TH3F *final_cos_init_pt_n;
   TH3F *init_cos_final_pt_n;
   TH3F *final_cos_final_pt_n;

   TH3F *init_cos_init_pt_N;
   TH3F *final_cos_init_pt_N;
   TH3F *init_cos_final_pt_N;
   TH3F *final_cos_final_pt_N;

   TH1F *dpt_max;
   TH1F *dpt_ratio;
   TH1F *dpt_max_1;
   TH1F *dpt_ratio_ll;
   TH1F *dpt_ratio_l;
   TH1F *dpt_ratio_h;
   TProfile *v2_N_finalpt[6];
   TProfile *v2_N_initpt[6];
   TProfile *v2_pt_finalpt[8];
   TProfile *v2_pt_initpt[8];
   TProfile *v2_n_i[3];//this n is the n in very step
   TProfile *v2_n_f[3];//this n is the n in very step
   TProfile *v2_n_Noptcut;
   TH1F *test_phi;
   TH1F *test_phi_1;
   TH1F *test_phi_2;
   TH1F *test_phi_3;
   TH1F *itest_phi;
   TH1F *itest_phi_1;
   TH1F *itest_phi_2;
   TH1F *itest_phi_3;
   // Declaration of leaf types
   Int_t           mc_n;
   float           v2_initial;
   float           v2_final;
   vector<float>   *mc_pt;
   vector<float>   *mc_px;
   vector<float>   *mc_py;
   vector<float>   *mc_pz;
   vector<float>   *mc_m;
   vector<float>   *mc_eta;
   vector<float>   *mc_phi;
   vector<float>   *mc_vx_x;
   vector<float>   *mc_vx_y;
   vector<float>   *mc_vx_z;
   vector<float>   *mc_t;
//   vector<int>     *mc_status;
   vector<int>     *mc_pdgId;
   vector<int>     *mc_child_index;
   vector<int>     *mc_parent_index;

   // List of branches
   TBranch        *b_mc_n;   //!
   TBranch        *b_v2_initial;//!
   TBranch        *b_v2_final;//!
   TBranch        *b_mc_pt;   //!
   TBranch        *b_mc_px;   //!
   TBranch        *b_mc_py;   //!
   TBranch        *b_mc_pz;   //!
   TBranch        *b_mc_m;   //!
   TBranch        *b_mc_eta;   //!
   TBranch        *b_mc_phi;   //!
   TBranch        *b_mc_vx_x;   //!
   TBranch        *b_mc_vx_y;   //!
   TBranch        *b_mc_vx_z;   //!
   TBranch        *b_mc_t;   //!
//   TBranch        *b_mc_status;   //!
   TBranch        *b_mc_pdgId;   //!
   TBranch        *b_mc_child_index;   //!
   TBranch        *b_mc_parent_index;   //!

   CBNTanalyser(TTree * /*tree*/ =0) : fChain(0) { }
   virtual ~CBNTanalyser() { }
   virtual Int_t   Version() const { return 2; }
   virtual void    Begin(TTree *tree);
   virtual void    SlaveBegin(TTree *tree);
   virtual void    Init(TTree *tree);
   virtual Bool_t  Notify();
   virtual Bool_t  Process(Long64_t entry);
   virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
   virtual void    SetOption(const char *option) { fOption = option; }
   virtual void    SetObject(TObject *obj) { fObject = obj; }
   virtual void    SetInputList(TList *input) { fInput = input; }
   virtual TList  *GetOutputList() const { return fOutput; }
   virtual void    SlaveTerminate();
   virtual void    Terminate();

   ClassDef(CBNTanalyser,0);
};

#endif

#ifdef CBNTanalyser_cxx
void CBNTanalyser::Init(TTree *tree)
{
   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set object pointer
   mc_pt = 0;
   mc_px = 0;
   mc_py = 0;
   mc_pz = 0;
   mc_m = 0;
   mc_eta = 0;
   mc_phi = 0;
   mc_vx_x = 0;
   mc_vx_y = 0;
   mc_vx_z = 0;
   mc_t = 0;
//   mc_status = 0;
   mc_pdgId = 0;
   mc_child_index = 0;
   mc_parent_index = 0;
   // Set branch addresses and branch pointers
   if (!tree) return;
   fChain = tree;
   fChain->SetMakeClass(1);

   fChain->SetBranchAddress("mc_n", &mc_n, &b_mc_n);
   fChain->SetBranchAddress("v2_initial", &v2_initial, &b_v2_initial);
   fChain->SetBranchAddress("v2_final", &v2_final, &b_v2_final);
   fChain->SetBranchAddress("mc_pt", &mc_pt, &b_mc_pt);
   fChain->SetBranchAddress("mc_px", &mc_px, &b_mc_px);
   fChain->SetBranchAddress("mc_py", &mc_py, &b_mc_py);
   fChain->SetBranchAddress("mc_pz", &mc_pz, &b_mc_pz);
   fChain->SetBranchAddress("mc_m", &mc_m, &b_mc_m);
   fChain->SetBranchAddress("mc_eta", &mc_eta, &b_mc_eta);
   fChain->SetBranchAddress("mc_phi", &mc_phi, &b_mc_phi);
   fChain->SetBranchAddress("mc_vx_x", &mc_vx_x, &b_mc_vx_x);
   fChain->SetBranchAddress("mc_vx_y", &mc_vx_y, &b_mc_vx_y);
   fChain->SetBranchAddress("mc_vx_z", &mc_vx_z, &b_mc_vx_z);
   fChain->SetBranchAddress("mc_t", &mc_t, &b_mc_t);
//   fChain->SetBranchAddress("mc_status", &mc_status, &b_mc_status);
   fChain->SetBranchAddress("mc_pdgId", &mc_pdgId, &b_mc_pdgId);
   fChain->SetBranchAddress("mc_child_index", &mc_child_index, &b_mc_child_index);
   fChain->SetBranchAddress("mc_parent_index", &mc_parent_index, &b_mc_parent_index);
}

Bool_t CBNTanalyser::Notify()
{
   // The Notify() function is called when a new file is opened. This
   // can be either for a new TTree in a TChain or when when a new TTree
   // is started when using PROOF. It is normally not necessary to make changes
   // to the generated code, but the routine can be extended by the
   // user if needed. The return value is currently not used.

   return kTRUE;
}

#endif // #ifdef CBNTanalyser_cxx
